package com.backend.models;

import io.ebean.ExpressionList;
import io.ebean.Finder;
import io.ebean.Model;
import lombok.Data;

import javax.persistence.*;
import java.util.Date;

@Entity
@Table(name = "product_comment")
@Data
public class ProductComment extends Model {
    @Id
    public Integer id;
    @ManyToOne
    @JoinColumn(name = "product_id")
    public Product product;
    public Integer userId;
    @ManyToOne
    @JoinColumn(name = "re_comment_id")
    public ProductComment reComment;
    public Date createTime;
    public String comment;
    public Boolean deleted = false;

    public static Finder<Integer, ProductComment> find = new Finder<>(ProductComment.class);

    public static ExpressionList<ProductComment> search() {
        return ProductComment.find.query().where();
    }
}
